import ajax from '@/utils/request'
import store from '@/store/index'
// console.log(store.getters.storeToken);

export function cartAddFn({ goodsId, goodsNum, goodsSkuId = '0' }) {
  // :5173/#/prodetail/10040:1 Uncaught (in promise) method param miss:goodsSkuId
  return ajax({
    url: '/cart/add',
    method: 'post',
    headers: {
      AccessToken: store.getters.storeToken,
      platform: 'APP',
    },
    data: {
      goodsId,
      goodsNum,
      goodsSkuId,
    }

  })
}

export function cartListFn() {
  return ajax({
    url: '/cart/list',

  })
}

export function cartUpdateFn({ goodsId, goodsNum, goodsSkuId }) {
  return ajax({
    url: '/cart/update',
    method: 'post',
    data: {
      goodsId,
      goodsNum,
      goodsSkuId
    }

  })
}

export function cartClear(cartIds) {

  return ajax({
    method: 'post',
    url: '/cart/clear',
    data: {
      cartIds
    }
  })

}